<%@page import="com.jfinal.kit.PropKit"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>  
<html>
<head>
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<!-- 新 Bootstrap 核心 CSS 文件 -->
		<link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">

		<!-- 可选的Bootstrap主题文件（一般不用引入） -->
		<link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">

		<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
		<script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>

		<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
		<script src="//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
		<link rel="stylesheet" href="http://tb1.bdstatic.com/??/tb/static-common/style/tb.js/dialog_29a9417.css,/tb/static-common/lib/tbui/style/all_1888f28.css" />
		<link rel="stylesheet" href="http://tb1.bdstatic.com/??/tb/_/index_7712603.css,/tb/_/search_2e2269a.css" />
		<link href="/wx/css/chongzhi.css" type="text/css" rel="stylesheet"/>
		<title>注册</title>
		<style>
		img{
			width:100%;
		}
		</style>
		<script>
		function checkTel(){
			var tel=$("#tel").val();
			if(tel==''){
				alert("请填写手机号！");
				return false;
			}else{
				var regu = /^0?1[3|4|5|8][0-9]\d{8}$/; 
				var re = new RegExp(regu);
				if(!(re.test(tel))){
					alert("请输入正确的手机号！");
					return false;
				}else{
					return true;
				}
			}

		}
			var i=60;
			function show() {
				if(checkTel()==false){
					return false;
				}else{
					var s=setInterval(time,1000);
					function time(){
						if(i==0){
							$(".getcode").show();
							$("#jishi").hide();
							clearInterval(s);
							i=5;
						}else{
							$(".getcode").hide();
							$("#jishi").show();
							$("#jishi").val(i+" 秒");
							i--;
						}
						
					}
			var inputcode = $(".code-input").val();
			var tel=$("#tel").val();
			
				 $.ajax({
					type : "POST",
					url : "../person/getRequest2",
					dataType : "json",
					data : {
						telNum:tel
					},
					success : function(data) {
					},
					error : function(data) {
					}
				}); 
				}
}
			function show2() {
				if(checkTel()){
					
					var inputcode = $(".code-input").val();
					
					if(inputcode==''){
						alert('验证码不能为空！');
						return false;
					}
					var telNum = $("#tel").val();
				$.ajax({
					type : "POST",
					url : "../person/getCode",
					dataType : "json",
					data : {
						inputcode:inputcode,
						telNum:telNum
					},
					success : function(data) {
						if(data!=null){
							var code = data["code"];
							if(code=="0"){
								location.href='../wx/jsp/carInfo.jsp';
							}else if(code="1"){
								alert("感谢您的配合!易行丁丁竭诚为您服务");
								location.href='../wx/jsp/carInfo.jsp';
								
							}else if(code="-1"){
								alert("验证码错误！");
							}
						}
					},
					error : function(data) {
						alert("录制信息失败！");
					}
				});
			}
			}
			
			function codeUp(){
				if(checkTel() && $(".code-input").val().length>0){
					$(".register-submit2").show();
					$(".register-submit").hide();
					}else{
						$(".register-submit").show();
						$(".register-submit2").hide();
						return false;
					}
			}
		</script>
	</head>

	<body>
		<div style="padding:10px">
			<img src="/wx/images/huo-register.jpg">
		</div>
		<div class="register-center">
			<div class="register-center-tel">
				<span>手机号码</span><input type="text" id="tel" placeholder="请输入您的手机号码"/><br>
			</div>
			<div class="register-center-code">
				<span>验证码</span><input type="text" class="code-input" onkeyup="codeUp()" placeholder="请输入验证码"/>
				<input type="button" class="getcode" value="获取验证码" onclick="show()" >
				<input type="button" class="getcode" value=""  id="jishi" hidden >
			</div>
		</div>
		<div style="margin:20px auto;width:90%;">
		<input class="register-submit" type="button" style="background:#ccc;" value="提交"/>
		<input class="register-submit2" type="button" style="display: none;" value="提交" onclick="show2()"/>
		</div>
	</body>
</html>